<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
use think\Request;
class Appointment extends Base
{
    //预约列表
    public function index()
    {
        //查预约清单
        $res1 = DB::name('appointment')
            ->alias('a')
            ->join('child c','a.child_id=c.child_id')
            ->join('vaccine v','a.vaccine_id=v.vaccine_id')
            ->join('hospital h','a.hospital_id=h.hospital_id')
            // ->where('a.user_id',$user_id)
            // ->field('child_name,vaccine_name,begin_time')
            ->where('appointment_status',0)
            ->order('appointment_id desc')
            ->select();
        //  dump($res1);
        // exit;
        $this->assign("res1",$res1);
         //查预约通过清单
        $res2 = DB::name('appointment')
            ->alias('a')
            ->join('child c','a.child_id=c.child_id')
            ->join('vaccine v','a.vaccine_id=v.vaccine_id')
            ->join('hospital h','a.hospital_id=h.hospital_id')
            // ->where('a.user_id',$user_id)
            ->where('appointment_status',1)
            ->order('appointment_id desc')
            ->select();
        $this->assign("res2",$res2);
       //查预约取消清单
       $res3 = DB::name('appointment')
            ->alias('a')
            ->join('child c','a.child_id=c.child_id')
            ->join('vaccine v','a.vaccine_id=v.vaccine_id')
            ->join('hospital h','a.hospital_id=h.hospital_id')
            // ->where('a.user_id',$user_id)
            ->where('appointment_status',2)
            ->order('appointment_id desc')
            ->select();
        $this->assign("res3",$res3);
        //查预约全部清单
        $res4 = DB::name('appointment')
            ->alias('a')
            ->join('child c','a.child_id=c.child_id')
            ->join('vaccine v','a.vaccine_id=v.vaccine_id')
            ->join('hospital h','a.hospital_id=h.hospital_id')
            // ->where('a.user_id',$user_id)
            ->order('appointment_id desc')
            ->select();
        $this->assign("res4",$res4);
        return $this->fetch();
    }
}